# -*- coding:utf-8 -*-
# @Time: 2020/9/16 20:23
# @Author: 周铖鑫
# @Description：legend的使用
# @File: UseLegend.py
import  matplotlib.pyplot as plt
import numpy as np
x=np.linspace(-3,3,50)
y1=x*2+1
y2=x**2
plt.figure(num=2,figsize=(10,4))
#放置两条线
#设置坐标轴范围
plt.xlim((-1,2))
plt.ylim((-2,3))
#设置坐标轴标签
plt.xlabel('I am x')
plt.ylabel('I am y')
new_ticks=np.linspace(-1,2,5)
print(new_ticks)
plt.xticks(new_ticks)
plt.yticks([-2,-1.8,-1,1.22,3],
            [r'$really\ bad$','$bad\ \\alpha$','$normal$','$good$','$really\ good$'])
l1,=plt.plot(x,y2,label='up')
l2,=plt.plot(x,y1,color='red',linewidth=1.0,linestyle='--',label='down')
plt.legend(handles=[l1,],labels=['aaa',],loc='best')
plt.show()